#ifndef _SCENE_H_
#define _SCENE_H_

#include "Base.h"
#include "Bullet.h"
#include "Constants.h"
#include "CollisionManager.h"
#include "..\..\Util\Logger.h"
#include "..\..\Util\Utils.h"
#include <string>
#include <map>
#include <list>

using namespace util;

namespace model
{
class Bonus;
class Asteroid;
class Ship;
class ISceneObserver;

class Scene
{
public:
	Scene(int, int);
	virtual ~Scene(void);
	void setObserver(ISceneObserver*);
	void initialize(void);
	void setAsteroids(list<Asteroid*>);

	list<Asteroid*> getAsteroids(void) { return asteroids;}
	list<Base*>		getBases	();
	list<Ship*>     getShips    ();
	list<Bullet*>   getBullets  () { return bullets;}
	list<Bonus*>    getBonus    () { return bonus;}

	void        setBackground(string filePath) { background = filePath;}
	std::string getBackground() { return background;}

	int getWidth(void);
	int getHeight(void);
	void accelerateShip(string shipId="1");
	void stopAcceleration(string shipId="1");
	void rotateShipToLeft(string shipId="1");
	void rotateShipToRight(string shipId="1");
	void stopRotation(string shipId="1");
	void addBase(std::string id, Base*);
	void addShip(std::string id, Ship*);
	void addBullet(double startTime, string shipId="1", Bullet::BulletType bt=Bullet::BULLET);
	void addBonus(double startTime, int x, int y);
	void update(double);
	std::string toString(void);
	void randomizeShipsPosition(void);
	void addChildAsteroid(Asteroid *parentAsteroid, int deltaDirection);
	void addNewRandomAsteroid(void);
	void clear(void);
	model::Ship* getShip(string clientID);
private:
	int    generateId(void);
	void   checkBordersAndEntityPosition(Entity*);
	bool   defineShipPosition(Ship* ship, int pos);
	double getAngleDiff(double angle1, double angle2, int delta);
	void   processCollisions(double);
	void   destroyEntity(Entity* e, bool removeFromContainers=true);
	void   checkEntityImage(Entity *e, string defaultImage);

	CollisionManager collisionManager;
	ISceneObserver* observer;
	list<Asteroid*>     asteroids;
	list<Bullet*>       bullets;
	list<Bonus*>        bonus;
	map<string, Base*>  bases;
	map<string, Ship*>  ships;
	map<int, Asteroid*> asteroidsMap;
	map<int, Bullet*>   bulletsMap;
	map<int, Bonus*>    bonusMap;
	map<int, Ship*>     shipsMap;
	string background;
	int width;
	int height;		
	double lastTime;
};
};

#endif
